ret = -ESRCH;
if ( d != NULL )
{
- domain_stop(d);
+ ret = -EINVAL;
+ if ( d != current )
+ {
+ domain_stop(d);
+ ret = 0;
+ }
put_domain(d);
- ret = 0;
}
}
break;
if ( d != current )
{
domain_kill(d);
- put_domain(d);
ret = 0;
}
+ put_domain(d);
}
}
break;
case DOM0_PINCPUDOMAIN:
{
domid_t dom = op->u.pincpudomain.domain;
+ struct domain *d = find_domain_by_id(dom);
+ int cpu = op->u.pincpudomain.cpu;
+
+ if ( d == NULL )
+ {
+ ret = -ESRCH;
+ break;
+ }
- if ( dom == current->domain || dom == IDLE_DOMAIN_ID )
+ if ( d == current )
+ {
ret = -EINVAL;
+ put_domain(d);
+ break;
+ }
+
+ if ( cpu == -1 )
+ {
+ clear_bit(DF_CPUPINNED, &d->flags);
+ }
else
{
- struct domain *d = find_domain_by_id(dom);
- int cpu = op->u.pincpudomain.cpu;
-
- ret = -ESRCH;
-
- if ( d != NULL )
- {
- if ( cpu == -1 )
- {
- clear_bit(DF_CPUPINNED, &d->flags);
- }
- else
- {
- domain_pause(d);
- set_bit(DF_CPUPINNED, &d->flags);
- cpu = cpu % smp_num_cpus;
- d->processor = cpu;
- domain_unpause(d);
- }
- put_domain(d);
- ret = 0;
- }
+ domain_pause(d);
+ set_bit(DF_CPUPINNED, &d->flags);
+ d->processor = cpu % smp_num_cpus;
+ domain_unpause(d);
}
+
+ put_domain(d);
}
break;
op->u.getdomaininfo.flags =
(test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0);
- domain_pause(d);
+ if ( d != current )
+ domain_pause(d);
op->u.getdomaininfo.domain = d->domain;
strcpy(op->u.getdomaininfo.name, d->name);
ret = -EINVAL;
gdi_out:
- domain_unpause(d);
+ if ( d != current )
+ domain_unpause(d);
put_domain(d);
}
break;
int cpu = d->processor;
spin_lock_irqsave(&schedule_lock[cpu], flags);
-
- if ( test_bit(DF_RUNNING, &d->flags) )
- cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
- else if ( __task_on_runqueue(d) )
- __del_from_runqueue(d);
-
+ if ( likely(!domain_runnable(d)) )
+ {
+ if ( test_bit(DF_RUNNING, &d->flags) )
+ cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
+ else if ( __task_on_runqueue(d) )
+ __del_from_runqueue(d);
+ }
spin_unlock_irqrestore(&schedule_lock[cpu], flags);
/* Synchronous. */
- while ( test_bit(DF_RUNNING, &d->flags) )
+ while ( test_bit(DF_RUNNING, &d->flags) && !domain_runnable(d) )
{
smp_mb();
cpu_relax();